package com.xmy.cultivate.service;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.xmy.cultivate.entity.*;
import com.baomidou.mybatisplus.extension.service.IService;
import com.xmy.cultivate.entity.views.ArrivalRate;
import com.xmy.cultivate.entity.views.RecordCourseStudent;
import com.xmy.cultivate.entity.views.SchedulingClash;
import com.xmy.cultivate.entity.views.SignResult;
import com.xmy.cultivate.enums.ReachTypeEnum;
import org.apache.ibatis.annotations.Param;
import org.springframework.scheduling.annotation.Async;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 排课详情 服务类
 * </p>
 *
 * @author min
 * @since 2022-08-01
 */
public interface ICourseSchedulingDetailService extends IService<CourseSchedulingDetail> {


    public abstract CourseSchedulingDetail getOneById(Long id);

    public abstract List<RecordCourseStudent> recordStudentList(Wrapper wrapper,Long schedulingId,Long gradeId,Long courseId,Long schoolId);

    public abstract List<CourseSchedulingDetail> findAll(Wrapper wrapper);

    public abstract IPage<CourseSchedulingDetail> findAllForPage(IPage<?> page,Wrapper wrapper);

    public abstract IPage<CourseSchedulingDetail> calendarList(IPage<CourseSchedulingDetail> page,Wrapper wrapper);

    public abstract List<CourseSchedulingDetail> getFindClash(Wrapper wrapper);

    public abstract IPage<CourseSchedulingDetail> getListByClassId(IPage<?> page, QueryWrapper queryWrapper);

    public abstract List<Student> getStudentList(String id);

    public abstract List<RepairCourse> getSchedulingUnionRepair(QueryWrapper queryWrapper);

    /**
     * 获取删除了的数据
     * @param id
     * @return
     */
    public abstract CourseSchedulingDetail getCourseSchedulingDetailById(Long id);

    public abstract List<RepairCourse> getSchedulingList(Integer yearPart, Integer quarterNum, Long schoolId, Long studentId, LocalDate schoolDate);

    public abstract boolean deleteForGradeId(Long gradeId,LocalDateTime dateTime);

    Integer getSchedulingCountForRecord(Long gradeId);

    public abstract Long getIsAt(Long gradeId, Integer lessonNum);

    Long getIsAtForDate(Long gradeId, LocalDate schoolDate);

    public abstract List<RepairCourse> getSchoolDateList(String schoolId, String gradeId, String teacherId, String schoolDate, String lessonType);

    public abstract List<ArrivalRate> arrivalRate(String schoolIdStr, String yearPart, String quarterNum, String type, String subjectsId, String startDate, String endDate, String timeStart, String timeEnd, Integer lessonType, boolean isHistory);

    /**
     *
     * @param schoolId
     * @param subjectsId
     * @param yearPart
     * @param quarterNum
     * @param startDate
     * @param endDate
     * @param gradeId
     * @param teacherId
     * @param type 1个人
     * @param status
     * @param timeStart
     * @param timeEnd
     * @param lessonType
     * @param isHistory
     * @return
     */
    public abstract List<RecordCourse> arrivalRateDetail(String schoolId,String subjectsId,String yearPart,String quarterNum,String startDate,String endDate,String gradeId,String teacherId,String type,String status,String timeStart,String timeEnd,Integer lessonType,boolean isHistory);

    List<SignResult> signInDetail(String schoolId, String subjectsId, String yearPart, String quarterNum, String startDate, String endDate, String gradeId, String teacherId, String type, String status, String timeStart, String timeEnd, Integer lessonType, String classTypeId, String studentName, boolean isHistory, List<RecordCourse> startAndEndList);

    List<SchedulingClash> schedulingClash(Integer yearPart, Integer quarterNum, Long schoolId, String studentId, String startDateTime, String endDateTime, String lessonType, String outSchedulingId);

    public abstract Long schedulingClashCount(Integer yearPart, Integer quarterNum, Long schoolId, Long studentId, String startDate, String endDate, String lessonType);

    //@Async("onlineAsync")
    void updateLessonNum(Long gradeId);

    /**
     * 获取下一次课
     * @param gradeId
     * @param schoolDate
     * @return
     */
    Integer getNextLessonNum(Long gradeId, LocalDate schoolDate);

    LocalDate getGradeMinDate(Long gradeId);

    LocalDate getGradeMaxDate(Long gradeId);

    List<RepairCourse> getCourseSchedulingList(Integer yearPart, Integer quarterNum, Long studentId, Long schoolId, String startSchoolDateTime);

    List<RepairCourse> getCourseSchedulingListByLessonType(Integer yearPart, Integer quarterNum, Long studentId, Long schoolId, String startSchoolDateTime, Integer lessonType);

    List<RepairCourse> getSchedulingClash(Integer yearPart, Integer quarterNum, Long studentId, Long gradeId, String localDateTime);

    List<RepairCourse> getSchedulingClashByLessonType(Integer yearPart, Integer quarterNum, Long studentId, Long gradeId, String localDateTime, Integer lessonType, LocalDateTime startDateTime, LocalDateTime endDateTime);

    List<CourseSchedulingDetail> getSchedulingClashForDate(Integer yearPart, Integer quarterNum, Long studentId, Long gradeId, String localDateTime);

    /**
     * 缺课
     */
    public abstract Boolean resumeClassesLackCourse(Long gradeId, Long studentId, Integer type, String createdAt, Integer lackType);


    List<CourseSchedulingDetail> getBeforSchedulingOne(Long schedulingDetailId,
                                                 Long schoolId,
                                                 Long studentId,
                                                 Long subjectsId,
                                                 Integer lessonType,
                                                 String schoolDate,
                                                 String startDateTime,
                                                 String endDateTime);

    RecordCourse addSiginScheduling(Long courseSchedulingDetailId, Long teacherId, Long studentId, String studentName, Integer type, Integer courseType, ReachTypeEnum reachTypeEnum, Long siginInTeacherId, LocalDateTime dateTimeNow, Integer signType, String subjectsId, Integer lessonType);
}
